<?php

namespace app\openapi\middleware;

use app\Request;
use Exception;
use think\facade\Session;

/**
 * 权限规则验证
 */
class AuthMiddleware
{
    /**
     * 权限规则验证
     * @param Request $request
     * @param \Closure $next
     * @return mixed
     * @throws \throwable
     */
    public function handle(Request $request, \Closure $next)
    {
        if(!Session::has('userid')){
            throw new Exception("请先登录", 401);
        }
        return $next($request);
    }
}
